// typescript中使用:指定类型
// function sayHello(person: String){
//     return 'Hello,'+person
// }

// let user = 'Tom'
// console.log(sayHello(user))

// interface Person{
//     firstName: string;
//     lastName: string
// }

// function greeter(person: Person){
//     return "Hello, "+person.firstName+" "+person.lastName
// }

// let user = {firstName: "Jane", lastName: "User"}
// console.log(greeter(user))


class Student {
    fullName: string;
    // 构造函数使用 public 等同于创建了同名的成员变量
    constructor(public firstName, public middleInitial, public lastName){
        this.fullName = firstName+" "+middleInitial+" "+lastName;
    }
}
interface Person{
    firstName: string;
    lastName: string;
}
function greeter(person: Person){
    return "Hello, "+person.firstName+" "+person.lastName
}

let user = new Student("Jane","M.","User");
console.log(greeter(user))